﻿using common.libs.extends;
using Microsoft.Extensions.DependencyInjection;
using common.server;
using System.Threading.Tasks;

namespace client.service.tcpforward
{
    public class TcpForwardMessenger : IMessenger
    {
        private readonly TcpForwardMessengerSender tcpForwardMessengerSender;
        public TcpForwardMessenger(TcpForwardMessengerSender tcpForwardMessengerSender)
        {
            this.tcpForwardMessengerSender = tcpForwardMessengerSender;
        }

        public void Execute(IConnection connection)
        {
            var data = connection.ReceiveRequestWrap.Memory.DeBytes<TcpForwardInfo>();
            tcpForwardMessengerSender.OnData.Push(new OnDataArg
            {
                Connection = connection,
                Data = data,
            });
        }
    }

}
